<?php
include('includes/header.php');
?>

<div id="main">
    <?php
    //only need to check the session or a variable
//     echo "<table>";
//     foreach ($_SERVER as $k => $s){
//     	echo "<tr style='text-align:left;'><td>[".$k."]</td><td>".$s."</td></tr>";
//     }
//     echo "</table>";
    if ($authenticated) {
        //success login, next authorize user
        if ($authorized) {
            echo "Username: " . $username . "<br />Role: " . $role;
            //continue the rest of the code, here...
        } else {
            echo "You are not authorized to view this page!!";
        }
    } else {
        //try to login, but failed
        if ($_GET['login']=='failed'){
            echo "<h2>Invalid Credential, please try again!</h2>";
        } else {
            //not login yet
            echo "<h2>Welcome, please login to start!</h2>";
        }
        ?>
    <div id="loginForm" style="border:0px solid;margin-left:25%;margin-right:25%;font-size:32px;">
        
        <form method="post" action="<?php echo $_GET['oriloc']; ?>" name="loginForm">
            <input type='hidden' value='login' name='action' />
            <table cellspacing="5" cellpadding="10" border="0" align="center">
                <tr><td>Student/Staff_ID:</td><td><input type="text" name="userid" value="" maxlength="16" class="tb" /></td></tr>
                <tr><td>Password:</td>
                    <td><input type="password" name="password" value="" maxlength="48" class="tb" /></td>
                </tr>
                <tr><td><input type="checkbox" name="keeplogin" value="K" />Keep me login</td>
                <td align="center"><div><input type="submit" name="btnLogin" value="Log In" class="button" /></div></td></tr>
            </table>
        </form>        
    </div>

        <?php
    }
    ?>
</div>
<?php include('includes/footer.php'); ?>